package com.education.business.service.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.education.business.mapper.SystemAdminRoleMapper;
import com.education.business.service.BaseService;
import com.education.model.entity.SystemAdminRole;
import com.education.model.entity.SystemRole;
import org.springframework.stereotype.Service;

/**
 * @author 余一
 * @date 2021/9/30  12:15
 */
@Service
public class SystemAdminRoleService extends BaseService<SystemAdminRoleMapper, SystemAdminRole> {


    public boolean checkRole(Integer id) {
        LambdaQueryWrapper<SystemAdminRole> wrapper = Wrappers.lambdaQuery(SystemAdminRole.class)
                .eq(SystemAdminRole :: getRoleId, id)
                .select(SystemAdminRole::getId)
                .last("limit 1");
        return super.getOne(wrapper) == null ? false : true;
    }

    public int deleteByAdminId(Integer id) {
        return baseMapper.delete(new QueryWrapper<SystemAdminRole>().eq("admin_id",id));
    }
}
